<%@page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<%@page import="java.sql.Connection,
java.sql.PreparedStatement,
java.sql.ResultSet,
java.sql.SQLException,
java.sql.Statement,
java.util.ArrayList,
java.util.Date,
java.util.List"
%>
<%@page import= "edu.gdut.imis.goods.common.*"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/register.css">
</head>
<body>
	<%
	
	String id = (String) session.getAttribute("uid");
	response.setContentType("text/html;charset=utf-8");
	request.setCharacterEncoding("utf-8");
	int uid= 0;
	String name = null;
	String password = null;
	String address = null;
	String mobile = null;
	String email = null;
	int status = 0;
	
	if(id==null){
	
		pageContext.forward("login.html");
	}
	if(!id.equals("")&&!id.equals("null")) {
	
		Connection conn = null;
		PreparedStatement pstmt = null;
		uid = Integer.parseInt(id);
		
		try {
		
			conn = DBConnector.getConn();
	
	
			String sql = "SELECT* FROM user_info WHERE id=(?)";
		
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, uid);
	
			ResultSet rs = pstmt.executeQuery();
		
				while(rs.next()){
				uid = rs.getInt(1);		
				
				name = rs.getString(2);
			
				//session.setAttribute("name", name);
				password = rs.getString(3);
				//session.setAttribute("password", password);
			
				address = rs.getString(4);
			
				//session.setAttribute("address", address);
				mobile =rs.getString(5);	
				//session.setAttribute("mobile", mobile);
				email =rs.getString(6);	
				//session.setAttribute("email", email);
    			status = rs.getInt(7);
    			//session.setAttribute("status", status);
    					
				}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
}else{
	out.print("<h3>还未登录</h3>");
}
	
	%>
	<div class="reg_form w">
                <form action="/Goods/UserModify" method="post">
                    <ul>
                    
                    
                        <li><label for="">账号:</label><input type="text" class="inp"  name="id" readonly="readonly" value="${uid}"></li>
                       
                        <li><label for="">昵称:</label><input type="text" class="inp" name="name" value="<%=name%>" ></li>
                       
                        <li><label for="">登录密码:</label><input type="password" class="inp" name="password" value="<%=password%>" ></li>
                        <li><label for="">地址:</label><input type="text" class="inp" name="address" value="<%=address%>" ></li>
                        <li><label for="">手机:</label><input type="text" class="inp" name="mobile" value="<%=mobile%>" ></li>
                        <li><label for="">邮箱:</label><input type="text" class="inp" name="email" value="<%=email%>" ></li>
                        <li><label for="">状态:</label><input type="text" class="inp" name="status" value="<%=status%>" ></li>
                        <li ><input type="submit" class="complete" value="确认修改"></li>
                    </ul>
                </form>
                
            </div>
</body>
</html>